﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Contrast
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
           int ishave= SqlDbHelper.ExecuteScalar("select 1 from hospital_info where name ='" + this.textBox1.Text + "'");
            if (ishave > 0)
            {
                MessageBox.Show("这个医院名称已经存着");
            }
            else
            {
               int isok= SqlDbHelper.ExecuteNonQuery("insert into hospital_info values ('" + this.textBox1.Text + "')");
                if (isok <= 0)
                {
                    MessageBox.Show("添加医院失败");
                }
                else
                {
                    DialogResult = DialogResult.OK;
                }
            }
        }
    }
}
